package com.lzy.cloud.payment.pay.weixin;

import com.lzy.framework.tools.commons.PropertiesUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.Properties;

public class Config {

    static Log LOG = LogFactory.getLog(Config.class);

    //=======【APP支付接口基本信息设置】============================
    public static String APPID;
    public static String MCHID;
    public static String APPSECRET;
    public static String KEY;
    public static String CHARSET;
    public static String SIGNTYPE;
    public static String FEE;


    //=======【支付结果通知url】=====================================
    /* 支付结果通知回调url，用于商户接收支付结果
    */
    public static String NOTIFY_URL;

    //=======【商户系统后台机器IP】===================================== 
    /* 此参数可手动配置也可在程序中自动获取
    */
    public static String IP;

    //统一下单地址
    public static String UNIFIEDORDER_URL;

    //退款地址
    public static String REFUND_URL;

    //退款地址查询
    public static String REFUND_QUERY_URL;

    //微信退款证书
    public static String CERT_P12;

    //获取openid地址--web公众号支付
    public static String WECHAT_OPENID_URL;
    //获取微信登录后用户个人信息
    public static String WECHAT_USERINFO;

    //获取openid--小程序
    public static String WECHAT_JS_OPENID_URL;

    //=======【公众账号支付接口基本信息设置】============================
    public static String WEB_APPID;
    public static String WEB_APPSECRET;
    public static String WEB_MCHID;
    public static String WEB_CERT_P12; //微信退款证书

    //=======【小程序账号支付接口基本信息设置】============================
    public static String SMALL_APPLET_APPID;
    public static String SMALL_APPLET_APPSECRET;

    static {

        try {
            Properties pro = PropertiesUtils.load("props/weixin.properties");
            //APP支付
            APPID = pro.getProperty("APPID");
            MCHID = pro.getProperty("MCHID");
            APPSECRET = pro.getProperty("APPSECRET");
            KEY = pro.getProperty("KEY");
            CHARSET = pro.getProperty("CHARSET");
            SIGNTYPE = pro.getProperty("SIGNTYPE");
            NOTIFY_URL = pro.getProperty("NOTIFY_URL");
            IP = pro.getProperty("IP");
            UNIFIEDORDER_URL = pro.getProperty("UNIFIEDORDER_URL");
            REFUND_URL = pro.getProperty("REFUND_URL");
            REFUND_QUERY_URL = pro.getProperty("REFUND_QUERY_URL");
            CERT_P12 = pro.getProperty("CERT_P12");
            WECHAT_OPENID_URL = pro.getProperty("WECHAT_OPENID_URL");
            FEE = pro.getProperty("FEE");

            //公众账号支付
            WEB_APPID = pro.getProperty("WEB_APPID");
            WEB_APPSECRET = pro.getProperty("WEB_APPSECRET");
            WEB_MCHID = pro.getProperty("WEB_MCHID");
            WEB_CERT_P12 = pro.getProperty("WEB_CERT_P12");
            WECHAT_USERINFO = pro.getProperty("WECHAT_USERINFO");
            WECHAT_JS_OPENID_URL = pro.getProperty("WECHAT_JS_OPENID_URL");

            //小程序支付
            SMALL_APPLET_APPID = pro.getProperty("SMALL_APPLET_APPID");
            SMALL_APPLET_APPSECRET = pro.getProperty("SMALL_APPLET_APPSECRET");
        } catch (Exception e) {
            LOG.error("微信支付参数初始化出错......" + e.getMessage());
            e.printStackTrace();
        }
    }
}
